package 剑指offer;

import java.util.LinkedList;
import java.util.List;


public class _34二叉树中和为某一值的路径 {
		public static void main(String[] args) {
			LinkedList<Integer> list=new LinkedList<>();
			list.add(1);
			
		}
		List<List<Integer>> res=new LinkedList<List<Integer>>();
		LinkedList<Integer> list=new LinkedList<>();
	   public List<List<Integer>> pathSum(TreeNode root, int sum) {
		   recur(root, sum);
		   return res;
	    }
	   public void recur(TreeNode root,int sum) {
		   if(root==null) return;
		   sum-=root.val;
		   list.add(root.val);
		   if(sum==0&&root.left==null&&root.right==null) 		 
			   res.add(new LinkedList<Integer>(list)); 		   		   
		   recur(root.left, sum);
		   recur(root.right, sum);			
		   list.removeLast();
	   }
			
		
		
	}


